package com.zbkj.admin.controller.brand;


import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.zbkj.common.exception.AppException;
import com.zbkj.common.model.page.PageDiy;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.CommonBatchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.page.PageDiyEditNameRequest;
import com.zbkj.common.request.page.PageDiyRequest;
import com.zbkj.common.response.page.PageDiyResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.PageDiyService;
import com.zbkj.service.service.SystemConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * 家乡购 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/brand/goods/location")
@Api(tags = "家乡购管理") //配合swagger使用

public class BrandGoodsLocationController {

    @Autowired
    private SystemConfigService systemConfigService;

    @ApiOperation(value = "保存家乡购分类")
    @RequestMapping(value = "/goods/location/category/save", method = RequestMethod.POST)
    public CommonResult<Boolean> goodsLocationCategorySave(@RequestBody @Validated CommonBatchRequest request) {
        if (systemConfigService.goodsLocationCategorySave(request)) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    @ApiOperation(value = "家乡购分类")
    @RequestMapping(value = "/goods/location/category/list", method = RequestMethod.POST)
    public CommonResult<List<Integer>> goodsLocationCategoryList() {
        return CommonResult.success(systemConfigService.getGoodsLocationCategoryList());
    }

    @ApiOperation(value = "已配置的家乡购联盟类型")
    @RequestMapping(value = "/goods/location/alliance-type/list", method = RequestMethod.POST)
    public CommonResult<List<Integer>> goodsLocationAllianceTypeList() {
        return CommonResult.success(systemConfigService.goodsLocationAllianceTypeList());
    }
}